/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.sgs.persist;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author MaUrO FiLhO
 */
@Entity
@Table(name = "item_pedido")
@NamedQueries({
    @NamedQuery(name = "ItemPedido.findAll", query = "SELECT i FROM ItemPedido i"),
    @NamedQuery(name = "ItemPedido.findByIdItem", query = "SELECT i FROM ItemPedido i WHERE i.idItem = :idItem"),
    @NamedQuery(name = "ItemPedido.findByStatus", query = "SELECT i FROM ItemPedido i WHERE i.status = :status"),
    @NamedQuery(name = "ItemPedido.findByCotar", query = "SELECT i FROM ItemPedido i WHERE i.cotar = :cotar")})
public class ItemPedido implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id_item")
    private Integer idItem;
    @Column(name = "status")
    private String status;
    @Column(name = "cotar")
    private String cotar;
    @JoinColumn(name = "id_suprimento", referencedColumnName = "id_suprimento")
    @ManyToOne(optional = false)
    private Suprimento suprimento;
    @JoinColumn(name = "id_pedido", referencedColumnName = "id_pedido")
    @ManyToOne(optional = false)
    private Pedido pedido;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "itemPedido")
    private List<Cotacao> cotacaoList;

    public ItemPedido() {
    }

    public ItemPedido(Integer idItem) {
        this.idItem = idItem;
    }

    public Integer getIdItem() {
        return idItem;
    }

    public void setIdItem(Integer idItem) {
        this.idItem = idItem;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getCotar() {
        return cotar;
    }

    public void setCotar(String cotar) {
        this.cotar = cotar;
    }

    public Suprimento getSuprimento() {
        return suprimento;
    }

    public void setSuprimento(Suprimento suprimento) {
        this.suprimento = suprimento;
    }

    public Pedido getPedido() {
        return pedido;
    }

    public void setPedido(Pedido pedido) {
        this.pedido = pedido;
    }

    public List<Cotacao> getCotacaoList() {
        return cotacaoList;
    }

    public void setCotacaoList(List<Cotacao> cotacaoList) {
        this.cotacaoList = cotacaoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idItem != null ? idItem.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ItemPedido)) {
            return false;
        }
        ItemPedido other = (ItemPedido) object;
        if ((this.idItem == null && other.idItem != null) || (this.idItem != null && !this.idItem.equals(other.idItem))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.sgs.persist.ItemPedido[idItem=" + idItem + "]";
    }

}
